﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using AndBurn.DDSReader;

namespace DnPakExplorer.Controls {
	public partial class AniPictureBox : UserControl {

		private Image mAniImage;
		private int mFrameCount = 4;
		private int mCurrentFrame = 0;
		private int mGridHeight;

		public AniPictureBox() {
			InitializeComponent();
			mAniImage = new DDSImage(Properties.Resources.loadingani_a).BitmapImage;
			mGridHeight = mAniImage.Height/mFrameCount;
			timer1.Start();
		}

		private void AniPictureBox_Paint(object sender, PaintEventArgs e) {
			Rectangle clientRect = ClientRectangle;
			e.Graphics.DrawImage(mAniImage, clientRect, new Rectangle(0, mCurrentFrame*mGridHeight, mAniImage.Width, mGridHeight), GraphicsUnit.Pixel);
			Win32.InvertRect(e.Graphics.GetHdc(), ref clientRect);
		}

		private void timer1_Tick(object sender, EventArgs e) {
			mCurrentFrame++;
			if (mCurrentFrame >= mFrameCount)
				mCurrentFrame = 0;
			Refresh();
		}
	}
}
